<template>
	<view>
		<scroll-view scroll-y class="page">
			<!-- 头部 -->
			<cu-custom bgColor="bg-rgb" :isBack="true">
				<block slot="backText">返回</block>
				<block slot="content">FEEDER保养</block>
			</cu-custom>
			<!-- 查询条件 -->
			<view class="fixed" :style="[{animationDelay: 0.1 + 's'}]">
				<form>
					<view class="cu-form-group last">
						<image class="icon" src="../../static/saomiao.png" mode=""></image>
						<input auto-focus placeholder="请扫描单号" name="input" v-model="myFormData.orderCode" @confirm="inputQuery"></input>
					</view>
				</form>
			</view>
			<!-- 数据列表 -->
			<view class="list">
				<view class="card animation-slide-bottom" v-for="(item,index) in list" :key="index" 
				 :style="[{animationDelay: (index + 1)*0.1 + 's'}]">
					<view class="top">
						<view class="left">FEEDER SN：<text>{{item.feederSn}}</text></view>
						<!-- <view class="right">{{item.orderType}}</view> -->
					</view>
					<view class="line"></view>
					<view class="bottom">
						<view class="box">
							<view class="lable">
								批次数量:
							</view>
							<view class="content">
								{{item.batchNum}}
							</view>
						</view>
						<view class="box">
							<view class="lable">
								FEEDER规格:
							</view>
							<view class="content">
								{{item.feederGague}}
							</view>
						</view>
						<view class="box">
							<view class="lable">
								FEEDER类型:
							</view>
							<view class="content">
								{{item.feederType}}
							</view>
						</view>
						<view class="box">
							<view class="lable">
								FEEDER ID:
							</view>
							<view class="content">
								{{item.feederId}}
							</view>
						</view>
						<view class="box">
							<view class="lable">
								使用点数上限:
							</view>
							<view class="content">
								{{item.pointnumLimit}}
							</view>
						</view>
						<view class="box">
							<view class="lable">
								使用点数:
							</view>
							<view class="content">
								{{item.query1}}
							</view>
						</view>
						<view class="box">
							<view class="lable">
								使用周期上限:
							</view>
							<view class="content">
								{{item.cycleLimit}}
							</view>
						</view>
						<view class="box">
							<view class="lable">
								保养点数:
							</view>
							<view class="content">
								{{item.maintainPointnum}}
							</view>
						</view>
						<view class="box">
							<view class="lable">
								提醒点数:
							</view>
							<view class="content">
								{{item.remindPointnum}}
							</view>
						</view>
						<view class="box">
							<view class="lable">
								保养周期:
							</view>
							<view class="content">
								{{item.maintainCycle}}
							</view>
						</view>
						<view class="box">
							<view class="lable">
								提醒天数:
							</view>
							<view class="content">
								{{item.remindDays}}
							</view>
						</view>
						<view class="box">
							<view class="lable">
								最近保养日期:
							</view>
							<view class="content">
								{{item.query2}}
							</view>
						</view>
						<view class="box">
							<view class="lable">
								保养人:
							</view>
							<view class="content">
								{{item.query3}}
							</view>
						</view>
					</view>
					<view class="line"></view>
					<view class="btns">
						<view class="btn3" @click="goPage(item.id)">确认保养</view>
					</view>
				</view>
			</view>
			<view class="none" v-if="noDataAvailable">
				<view class="none1">
					暂无数据
				</view>
			</view>
			<!-- <view class="none2" v-if="noMoreDataAvailable">
				没有更多数据
			</view> -->
		</scroll-view>
	</view>
</template>

<script>
	export default {
		name: 'receive',
		data() {
			return {
				myFormData: {
					orderCode: '' // 输入框 查询值  根据单号查询
				},
				list: [], // 收货单列表
				pageNo: 1, // 上拉加载分页
				noDataAvailable: false, // 暂无数据 状态
				noMoreDataAvailable: false, // 没有更多数据 状态
				statusList:[]
			}
		},
		onShow() {
			this.pageNo = 1
			this.list = []
		},
		onLoad(e) {
			
		},
		onPullDownRefresh: function() {
			let _this = this
			_this.pageNo = 1
			_this.list = []
			setTimeout(function() {
				uni.stopPullDownRefresh();
				_this.getPurchaseOrder()
			}, 1000);
		},
		methods: {
			goPage(id) {
				uni.showModal({
					title: '',
					content: '确认保养吗?',
					cancelText: '取消',
					confirmText: '确认',
					success: res => {
						if (res.confirm) {
							this.$http.put('chiefdata/mesChiefdataFeeder/feederFix',{
								id:id
							}).then(res=>{
								if(res.data.code === 200){
									// this.$tip.success('操作成功!')
                  this.modal.show({ type:'success', content:'操作成功!' })
									this.list = []
									this.myFormData.orderCode = ''
								}else{
									// this.$tip.error(res.data.message)
                  this.modal.show({ type:'error', content:res.data.message })
								}
							})
						}
					}
				})
			},
			// 订单管理—采购订单-分页列表查询
			getPurchaseOrder() {
				uni.showLoading({
					mask:true,
					title:'加载中.....'
				})
				this.noDataAvailable = false
				// this.noMoreDataAvailable = false
				let data = {
					sn:this.myFormData.orderCode,
				}
				let _this = this
				this.$http.get('chiefdata/mesChiefdataFeeder/queryBySn', {
					params: data
				}).then(res => {
					uni.hideLoading()
					_this.list = [];
					if (res.data.success) {
						_this.list[0] = res.data.result;
						if (_this.list.length == 0) {
							_this.noDataAvailable = true;
						}
						console.log(_this.list)
					} else {
						// _this.$tip.error(res.data.message)
            _this.modal.show({ type:'error', content:res.data.message })
					}
				})
			},
			// 输入框查询
			inputQuery(){
				console.log(this.myFormData.orderCode)
				this.pageNo = 1;
				this.list=[];
				this.getPurchaseOrder();
				this.myFormData.orderCode = ''
			},
			// 备注展开
			showNote(index){
				this.$set(this.statusList, index, !this.statusList[index]);
				console.log(this.statusList[index])
			}
		},
	}
</script>

<style lang="less">
	page {
		background-color: #f1f1f1;
		.fixed {
			position: fixed;
			z-index: 1;
			width: 100%;
			background-color: white;
			height: 100rpx;
			border-bottom: 1rpx solid #eee;
			.last {
				border-bottom: 1rpx solid #eee;
				position: relative;
				.icon {
					width: 30rpx;
					height: 29rpx;
					position: absolute;
					top: 36rpx;
					left: 60rpx;
				}
				input {
					width: 686rpx;
					height: 68rpx;
					background: #FFFFFF;
					border: 1px solid #D5D8DF;
					border-radius: 34px;
					padding-left: 79rpx;
				}
			}
		}
		.list {
			margin-top: 120rpx;
			.card {
				margin: 30rpx;
				box-shadow: 0px 0px 5rpx 2rpx rgba(0, 0, 0, 0.1);
				border-radius: 10rpx;
				background-color: white;
				.top {
					display: flex;
					align-items: center;
					justify-content: space-between;
					// border-bottom: 20rpx solid #F0F0F0;
					// padding-bottom: 20rpx;
					font-weight: bold;
					padding:20rpx 30rpx;
					.left{
						font-size: 28rpx;
						font-family: PingFang SC;
						font-weight: 400;
						color: #485A75;
						line-height: 50rpx;
					}
					.right{
						font-size: 28rpx;
						font-family: PingFang SC;
						font-weight: bold;
						color: #191919;
						line-height: 50rpx;
					}
				}
				.line{
					width: 750rpx;
					height: 10rpx;
					background: #F3F5F9;
				}
				.bottom{
					padding:20rpx 30rpx;
					.box {
						display: flex;
						justify-content: space-between;
						padding: 20rpx 0;
						align-items: center;
						.lable {
							color: #485A75;
							font-size: 28rpx;
						}
						.content {
							width: 70%;
							text-align: right;
							color: #191919;
							font-weight: bold;
							word-break: break-all;
						}
						.shrink {
							height: 40rpx;
							overflow: hidden;
							white-space: nowrap;
							/*不换行*/
							text-overflow: ellipsis;
							/*超出部分文字以...显示*/
							font-weight: 400;
						}
						
						.unfold {
							text-align: left;
							font-weight: 400;
						}
					}
				}
				.btns {
					display: flex;
					justify-content: space-between;
					flex-direction: row-reverse;
					align-items: center;
					padding: 0 20rpx;
					font-size: 25rpx;
					padding:20rpx 30rpx;
					view{
						width: 180rpx;
						height: 64rpx;
						line-height: 50rpx;
						color: white;
						border-radius: 30rpx;
						padding: 10rpx 20rpx;
						text-align: center;
					}
					.btn1 {
						background-image: radial-gradient(circle,#3F55E9,#5F71ED,#7D8CF0);
					}
					.btn2 {
						background-image: radial-gradient(circle,#716BA9,#362D85,#57509A);
					}
					.btn3 {
						background-image: radial-gradient(circle,#354D9E,#354D9E,#697BB7);
					}
				}
			}
		}
	}

	.none .none1 {
		font-size: 30rpx;
		text-align: center;
		margin-top: 50rpx;
		color: #999999;
	}

	.none2 {
		font-size: 30rpx;
		text-align: center;
		margin-top: 50rpx;
		color: #999999;
	}
</style>
